package java_0391_single;

/**
 * 单例模式
 * 懒汉式
 */
public class SingleTon02 {
    public static void main(String[] args) {

    }
}

class Cat {
    private String name;
    private static Cat cat;//默认为null

    private Cat(String name) {
        this.name = name;
    }

    public static Cat getInstance() {
        if (cat == null) {
            cat = new Cat("cat");
        }
        return cat;
    }

}
